##################################################
##                                              ##
## NO LONGER USING... USING FILTER.PY INSTEAD.  ##
##                                              ##
##################################################

#Kyle Bakken, Chelsea Evans, Adam Lamb - Group 6
#CS419-400
#Description: This program will search through a text document and fill an Appointment object 
#with details on an advisor appointment
#Input: This program takes a plain text document
#Output: This program makes and fills an Appointment object
#TO DO: Optimize code, let user define text file name

import os
import objects
import string
import re

f = open('email1.txt', 'r')	#open the email... this will be changed
app = objects.Appointment	#instantiate a new appointment object

text = f.readline()
start = 0
end = text.find('\n')
app.advisor = text[start:end]	#the first line is the advisors name
print app.advisor 	#for testing

f.readline()
f.readline()
f.readline()
f.readline()

while True:
	text = f.readline()
	if "confirmed" in text:
		app.app_type = "confirm"
		break
	if "CANCELLED" in text:
		app.app_type = "cancel"
		break
print app.app_type	#for testing

text = f.readline()
start = text.find(' ') + 1
end = text.find('\n')
app.advisee = text[start:end]
print app.advisee	#for testing

text = f.readline()
start = text.find(' ') + 1
end = text.find('\n')
app.email = text[start:end]
print app.email	#for testing

text = f.readline()
start = text.find(' ') + 1
end = text.find('\n')
app.date = text[start:end]
print app.date	#for testing

text = f.readline()
start = text.find(' ') + 1
end = text.find('\n')
app.time = text[start:end]
print app.time	#for testing

f.close